package com.bear.demo1;

import java.util.concurrent.FutureTask;

/** 创建线程
 * @author LiuShanshan
 * @version V1.0
 * @Description
 */
public class CreateThrad {



    public static void main(String[] args) {
//        ThreadInit();
//        RunnableInit();
        FutureTaskInit();
    }


    public static void ThreadInit(){
        // thread创建线程1
        Thread threaddemo1 = new Thread("线程1thread方式创建") {
            @Override
            public void run() {
                System.out.println(Thread.currentThread().getName());
            }
        };
        threaddemo1.start();
        System.out.println("主线程");
    }

    public static void RunnableInit(){
        Runnable runnable = new Runnable() {
            @Override
            public void run() {
                System.out.println("第二个线程测试");
            }
        };
        Thread thread = new Thread(runnable);
        thread.start();
    }

    public static void FutureTaskInit(){
        FutureTask futureTask = new FutureTask(new Runnable() {
            @Override
            public void run() {
                System.out.println("FutureTask执行");
            }
        }, "gogo");
        Thread thread = new Thread(futureTask);
        thread.start();
    }



}

